<template>
  <div class="address">
   <van-nav-bar
  title="添加新地址"
  left-arrow
  @click-left="onClickLeft"
/>
<van-address-edit
  :area-list="areaList"
  show-postal
  show-set-default
  show-search-result
  :search-result="searchResult"
  :area-columns-placeholder="['请选择', '请选择', '请选择']"
  @save="onSave"
  @change-detail="onChangeDetail"
/>
  </div>
</template>

<script>
import { Toast } from 'vant'
import { areaList } from '@vant/area-data'
export default {
  name: 'addd',
  data() {
    return {
      searchResult: [],
      areaList,
    }
  },
  methods: {
    onClickLeft() {
      this.$router.back()
    },

    onSave(value) {
      this.$store.commit('address/saveAddress', value)
      console.log(value)
      console.log(this.$store.state.address.addRess)
      this.$router.push('/order')
    },
    onDelete() {
      Toast('delete')
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: '春熙路',
            address: '1号',
          }, {
            name: '肖家河',
            address: '肖家河大厦',
          },
        ]
      } else {
        this.searchResult = []
      }
    },
  },
}
</script>

<style lang="less" scoped>

</style>
